#include "interval_tests.hpp"
#include <boost/test/auto_unit_test.hpp>
#include <boost/test/test_case_template.hpp>
#include <boost/mpl/list.hpp>
#include <sstream>

using namespace utils;

typedef boost::mpl::list< interval_test_fixture< int> > test_types;


namespace 
{

BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingEmpty, TestFixture, test_types)
{
	TestFixture fixture;
	typename TestFixture::interval_set_type interval;
	fixture.prepare_first_interval( interval);
	BOOST_CHECK_EQUAL( 1, interval.size());
	CHECK_INTERVAL( fixture.values_[1], fixture.values_[3], *interval.begin());
}

// --------------------------------------------------------------------------------------------------------------------

BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingStartBeforeEndBefore, TestFixture, test_types)
{
	// Test adding at the beginning
	//                 |=========|
	// |^^^^^^^^^^|
	TestFixture fixture;
	typename TestFixture::interval_set_type interval;
	fixture.prepare_second_interval( interval);
	fixture.prepare_first_interval( interval);
	BOOST_CHECK_EQUAL( 2, interval.size());
	CHECK_INTERVAL( fixture.values_[1], fixture.values_[3], *interval.begin());
}

// --------------------------------------------------------------------------------------------------------------------

BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingStartAfterEndAfter, TestFixture, test_types)
{
	// |=========|
	//                 |^^^^^^^^^^^|
	TestFixture fixture;
	typename TestFixture::interval_set_type interval;
	fixture.prepare_first_interval( interval);
	fixture.prepare_second_interval( interval);
	BOOST_CHECK_EQUAL( 2, interval.size());
	CHECK_INTERVAL( fixture.values_[5], fixture.values_[7], *(++interval.begin()));
}

// --------------------------------------------------------------------------------------------------------------------

BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingStartBeforeEndInside, TestFixture, test_types)
{
	//    |=========|
	// |^^^^^^^|
	TestFixture fixture;
	typename TestFixture::interval_set_type interval;
	fixture.prepare_first_interval( interval);
	interval.merge( fixture.values_[0], fixture.values_[2]);
	BOOST_CHECK_EQUAL( 1, interval.size());
	CHECK_INTERVAL( fixture.values_[0], fixture.values_[3], *interval.begin());
}

// --------------------------------------------------------------------------------------------------------------------

BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingStartInsideEndAfter, TestFixture, test_types)
{
	// |=========|
	//      |^^^^^^^|
	TestFixture fixture;
	typename TestFixture::interval_set_type interval;
	fixture.prepare_first_interval( interval);
	interval.merge( fixture.values_[2], fixture.values_[4]);
	BOOST_CHECK_EQUAL( 1, interval.size());
	CHECK_INTERVAL( fixture.values_[1], fixture.values_[4], *interval.begin());
}

// --------------------------------------------------------------------------------------------------------------------

BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingStartBeforeEndAfter, TestFixture, test_types)
{
	//    |=======|
	// |^^^^^^^^^^^^^|
	TestFixture fixture;
	typename TestFixture::interval_set_type interval;
	fixture.prepare_first_interval( interval);
	interval.merge( fixture.values_[0], fixture.values_[4]);
	BOOST_CHECK_EQUAL( 1, interval.size());
	CHECK_INTERVAL( fixture.values_[0], fixture.values_[4], *interval.begin());
}

// --------------------------------------------------------------------------------------------------------------------

BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingStartInsideEndInside, TestFixture, test_types)
{
	// |==========|
	//   |^^^^^^|
	TestFixture fixture;
	typename TestFixture::interval_set_type interval;
	interval.merge( fixture.values_[0], fixture.values_[4]);
	interval.merge( fixture.values_[1], fixture.values_[3]);
	BOOST_CHECK_EQUAL( 1, interval.size());
	CHECK_INTERVAL( fixture.values_[0], fixture.values_[4], *interval.begin());
}


// --------------------------------------------------------------------------------------------------------------------

BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingStartToStartEndToEnd, TestFixture, test_types)
{
	// |==========|
	// |^^^^^^^^^^|
	TestFixture fixture;
	typename TestFixture::interval_set_type interval;
	interval.merge( fixture.values_[0], fixture.values_[4]);
	interval.merge( fixture.values_[0], fixture.values_[4]);
	BOOST_CHECK_EQUAL( 1, interval.size());
	CHECK_INTERVAL( fixture.values_[0], fixture.values_[4], *interval.begin());
}

// --------------------------------------------------------------------------------------------------------------------

BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingStartInsideFirstEndInsideSecond, TestFixture, test_types)
{
	// |==========|     |==========|
	//          |^^^^^^^^^^|
	TestFixture fixture;
	typename TestFixture::interval_set_type interval;
	fixture.prepare_first_interval( interval);
	fixture.prepare_second_interval( interval);
	interval.merge( fixture.values_[2], fixture.values_[6]);
	BOOST_CHECK_EQUAL( 1, interval.size());
	CHECK_INTERVAL( fixture.values_[1], fixture.values_[7], *interval.begin());
}

// --------------------------------------------------------------------------------------------------------------------

BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingStartInsideFirstEndAfterSecond, TestFixture, test_types)
{
	// |==========|     |==========|
	//          |^^^^^^^^^^^^^^^^^^^^^^|
	TestFixture fixture;
	typename TestFixture::interval_set_type interval;
	fixture.prepare_first_interval( interval);
	fixture.prepare_second_interval( interval);
	interval.merge( fixture.values_[2], fixture.values_[8]);
	BOOST_CHECK_EQUAL( 1, interval.size());
	CHECK_INTERVAL( fixture.values_[1], fixture.values_[8], *interval.begin());
}

// --------------------------------------------------------------------------------------------------------------------

BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingStartAndEndBetweenIntervals, TestFixture, test_types)
{
	// |=========|           |=========|
	//              |^^^^^^|
	TestFixture fixture;
	typename TestFixture::interval_set_type interval;
	interval.merge( fixture.values_[1], fixture.values_[2]);
	interval.merge( fixture.values_[5], fixture.values_[6]);
	interval.merge( fixture.values_[3], fixture.values_[4]);
	BOOST_CHECK_EQUAL( 3, interval.size());
	CHECK_INTERVAL( fixture.values_[3], fixture.values_[4], *(++interval.begin()));
}

// --------------------------------------------------------------------------------------------------------------------

BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingStartToEnd, TestFixture, test_types)
{
	// |=========|           
	//           |^^^^^^|
	TestFixture fixture;
	typename TestFixture::interval_set_type interval;
	interval.merge( fixture.values_[1], fixture.values_[2]);
	interval.merge( fixture.values_[2], fixture.values_[3]);
	BOOST_CHECK_EQUAL( 1, interval.size());
	CHECK_INTERVAL( fixture.values_[1], fixture.values_[3], *interval.begin());
}

// --------------------------------------------------------------------------------------------------------------------

BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingEndToStart, TestFixture, test_types)
{
	//        |=========|           
	// |^^^^^^|
	TestFixture fixture;
	typename TestFixture::interval_set_type interval;
	interval.merge( fixture.values_[1], fixture.values_[2]);
	interval.merge( fixture.values_[0], fixture.values_[1]);
	BOOST_CHECK_EQUAL( 1, interval.size());
	CHECK_INTERVAL( fixture.values_[0], fixture.values_[2], *interval.begin());
}

// --------------------------------------------------------------------------------------------------------------------

BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingStartToEndAndEndToStart, TestFixture, test_types)
{
	// |=========|      |=========|           
	//           |^^^^^^|
	TestFixture fixture;
	typename TestFixture::interval_set_type interval;
	fixture.prepare_first_interval( interval);
	fixture.prepare_second_interval( interval);
	interval.merge( fixture.values_[3], fixture.values_[5]);
	BOOST_CHECK_EQUAL( 1, interval.size());
	CHECK_INTERVAL( fixture.values_[1], fixture.values_[7], *interval.begin());
}

// --------------------------------------------------------------------------------------------------------------------

BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingStartToEndAndEndToEnd, TestFixture, test_types)
{
	// |=========|      |=========|           
	//           |^^^^^^^^^^^^^^^^|
	TestFixture fixture;
	typename TestFixture::interval_set_type interval;
	fixture.prepare_first_interval( interval);
	fixture.prepare_second_interval( interval);
	interval.merge( fixture.values_[3], fixture.values_[7]);
	BOOST_CHECK_EQUAL( 1, interval.size());
	CHECK_INTERVAL( fixture.values_[1], fixture.values_[7], *interval.begin());
}

// --------------------------------------------------------------------------------------------------------------------

BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingStartToStartAndEndToStart, TestFixture, test_types)
{
	// |=========|      |=========|           
	// |^^^^^^^^^^^^^^^^|
	TestFixture fixture;
	typename TestFixture::interval_set_type interval;
	fixture.prepare_first_interval( interval);
	fixture.prepare_second_interval( interval);
	interval.merge( fixture.values_[1], fixture.values_[5]);
	BOOST_CHECK_EQUAL( 1, interval.size());
	CHECK_INTERVAL( fixture.values_[1], fixture.values_[7], *interval.begin());
}

// --------------------------------------------------------------------------------------------------------------------

// |======|               |======|
//          |^^^^| |^^^^|
BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingTwoSets01, TestFixture, test_types)
{
	TestFixture fixture;
	typename TestFixture::interval_set_type i1, i2;
	i1.merge( fixture.values_[0], fixture.values_[1]);
	i2.merge( fixture.values_[2], fixture.values_[3]);
	i2.merge( fixture.values_[4], fixture.values_[5]);
	i1.merge( fixture.values_[6], fixture.values_[7]);
	i1.merge( i2);
	BOOST_REQUIRE_EQUAL( 4, i1.size());
	CHECK_INTERVAL_N( fixture.values_[0], fixture.values_[1], i1.begin(), 0);
	CHECK_INTERVAL_N( fixture.values_[2], fixture.values_[3], i1.begin(), 1);
	CHECK_INTERVAL_N( fixture.values_[4], fixture.values_[5], i1.begin(), 2);
	CHECK_INTERVAL_N( fixture.values_[6], fixture.values_[7], i1.begin(), 3);
}

// --------------------------------------------------------------------------------------------------------------------

//        |====| |====|
// |^^^^|                |^^^^|
BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingTwoSets02, TestFixture, test_types)
{
	TestFixture fixture;
	typename TestFixture::interval_set_type i1, i2;
	i2.merge( fixture.values_[0], fixture.values_[1]);
	i1.merge( fixture.values_[2], fixture.values_[3]);
	i1.merge( fixture.values_[4], fixture.values_[5]);
	i2.merge( fixture.values_[6], fixture.values_[7]);
	i1.merge( i2);
	BOOST_REQUIRE_EQUAL( 4, i1.size());
	CHECK_INTERVAL_N( fixture.values_[0], fixture.values_[1], i1.begin(), 0);
	CHECK_INTERVAL_N( fixture.values_[2], fixture.values_[3], i1.begin(), 1);
	CHECK_INTERVAL_N( fixture.values_[4], fixture.values_[5], i1.begin(), 2);
	CHECK_INTERVAL_N( fixture.values_[6], fixture.values_[7], i1.begin(), 3);
}

// --------------------------------------------------------------------------------------------------------------------

//        |====|        |====|
// |^^^^|        |^^^^|        |^^^^|
BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingTwoSets03, TestFixture, test_types)
{
	TestFixture fixture;
	typename TestFixture::interval_set_type i1, i2;
	i2.merge( fixture.values_[0], fixture.values_[1]);
	i1.merge( fixture.values_[2], fixture.values_[3]);
	i2.merge( fixture.values_[4], fixture.values_[5]);
	i1.merge( fixture.values_[6], fixture.values_[7]);
	i1.merge( fixture.values_[8], fixture.values_[9]);
	i1.merge( i2);
	BOOST_REQUIRE_EQUAL( 5, i1.size());
	CHECK_INTERVAL_N( fixture.values_[0], fixture.values_[1], i1.begin(), 0);
	CHECK_INTERVAL_N( fixture.values_[2], fixture.values_[3], i1.begin(), 1);
	CHECK_INTERVAL_N( fixture.values_[4], fixture.values_[5], i1.begin(), 2);
	CHECK_INTERVAL_N( fixture.values_[6], fixture.values_[7], i1.begin(), 3);
	CHECK_INTERVAL_N( fixture.values_[8], fixture.values_[9], i1.begin(), 4);
}

// --------------------------------------------------------------------------------------------------------------------

//        |====| |====|
// |^^^^^^^^|            |^^^^|
BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingTwoSets04, TestFixture, test_types)
{
	TestFixture fixture;
	typename TestFixture::interval_set_type i1, i2;
	i2.merge( fixture.values_[0], fixture.values_[2]);
	i1.merge( fixture.values_[1], fixture.values_[3]);
	i1.merge( fixture.values_[4], fixture.values_[5]);
	i2.merge( fixture.values_[6], fixture.values_[7]);
	i1.merge( i2);
	BOOST_REQUIRE_EQUAL( 3, i1.size());
	CHECK_INTERVAL_N( fixture.values_[0], fixture.values_[3], i1.begin(), 0);
	CHECK_INTERVAL_N( fixture.values_[4], fixture.values_[5], i1.begin(), 1);
	CHECK_INTERVAL_N( fixture.values_[6], fixture.values_[7], i1.begin(), 2);
}

// --------------------------------------------------------------------------------------------------------------------

//        |====| |====|
// |^^^^^^^^^^^^^^^|      |^^^^|
BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingTwoSets05, TestFixture, test_types)
{
	TestFixture fixture;
	typename TestFixture::interval_set_type i1, i2;
	i2.merge( fixture.values_[0], fixture.values_[5]);
	i1.merge( fixture.values_[1], fixture.values_[3]);
	i1.merge( fixture.values_[4], fixture.values_[6]);
	i2.merge( fixture.values_[7], fixture.values_[8]);
	i1.merge( i2);
	BOOST_REQUIRE_EQUAL( 2, i1.size());
	CHECK_INTERVAL_N( fixture.values_[0], fixture.values_[6], i1.begin(), 0);
	CHECK_INTERVAL_N( fixture.values_[7], fixture.values_[8], i1.begin(), 1);
}

// --------------------------------------------------------------------------------------------------------------------

// 0      1    2 3    4 5   6    7
//        |====| |====|
// |^^^^^^^^^^^^^^^^^^^^|   |^^^^|
BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingTwoSets06, TestFixture, test_types)
{
	TestFixture fixture;
	typename TestFixture::interval_set_type i1, i2;
	i2.merge( fixture.values_[0], fixture.values_[5]);
	i1.merge( fixture.values_[1], fixture.values_[2]);
	i1.merge( fixture.values_[3], fixture.values_[4]);
	i2.merge( fixture.values_[6], fixture.values_[7]);
	i1.merge( i2);
	BOOST_REQUIRE_EQUAL( 2, i1.size());
	CHECK_INTERVAL_N( fixture.values_[0], fixture.values_[5], i1.begin(), 0);
	CHECK_INTERVAL_N( fixture.values_[6], fixture.values_[7], i1.begin(), 1);
}

// --------------------------------------------------------------------------------------------------------------------

// 0      1    2 3    4 5   6    7
// |====================|   |====|
//        |^^^^| |^^^^|
BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingTwoSets07, TestFixture, test_types)
{
	TestFixture fixture;
	typename TestFixture::interval_set_type i1, i2;
	i1.merge( fixture.values_[0], fixture.values_[5]);
	i2.merge( fixture.values_[1], fixture.values_[2]);
	i2.merge( fixture.values_[3], fixture.values_[4]);
	i1.merge( fixture.values_[6], fixture.values_[7]);
	i1.merge( i2);
	BOOST_REQUIRE_EQUAL( 2, i1.size());
	CHECK_INTERVAL_N( fixture.values_[0], fixture.values_[5], i1.begin(), 0);
	CHECK_INTERVAL_N( fixture.values_[6], fixture.values_[7], i1.begin(), 1);
}

// --------------------------------------------------------------------------------------------------------------------

// 0      1    2     3  4 5   6    7
// |====================|   |====|
//        |^^^^|     |^^^^|
BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingTwoSets08, TestFixture, test_types)
{
	TestFixture fixture;
	typename TestFixture::interval_set_type i1, i2;
	i1.merge( fixture.values_[0], fixture.values_[4]);
	i2.merge( fixture.values_[1], fixture.values_[2]);
	i2.merge( fixture.values_[3], fixture.values_[5]);
	i1.merge( fixture.values_[6], fixture.values_[7]);
	i1.merge( i2);
	BOOST_REQUIRE_EQUAL( 2, i1.size());
	CHECK_INTERVAL_N( fixture.values_[0], fixture.values_[5], i1.begin(), 0);
	CHECK_INTERVAL_N( fixture.values_[6], fixture.values_[7], i1.begin(), 1);
}

// --------------------------------------------------------------------------------------------------------------------

// 0      1    2 3 4      5 6  7
//        |====| |==========|
// |^^^^^^^^^^^^^^^|      |^^^^|
BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingTwoSets09, TestFixture, test_types)
{
	TestFixture fixture;
	typename TestFixture::interval_set_type i1, i2;
	i2.merge( fixture.values_[0], fixture.values_[4]);
	i1.merge( fixture.values_[1], fixture.values_[2]);
	i1.merge( fixture.values_[3], fixture.values_[6]);
	i2.merge( fixture.values_[5], fixture.values_[7]);
	i1.merge( i2);
	BOOST_REQUIRE_EQUAL( 1, i1.size());
	CHECK_INTERVAL_N( fixture.values_[0], fixture.values_[7], i1.begin(), 0);
}

// --------------------------------------------------------------------------------------------------------------------

// 0      1    2 3 4      5 6  7
// |^^^^^^^^^^^^^^^|      |^^^^|
//        |====| |==========|
BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingTwoSets10, TestFixture, test_types)
{
	TestFixture fixture;
	typename TestFixture::interval_set_type i1, i2;
	i1.merge( fixture.values_[0], fixture.values_[4]);
	i2.merge( fixture.values_[1], fixture.values_[2]);
	i2.merge( fixture.values_[3], fixture.values_[6]);
	i1.merge( fixture.values_[5], fixture.values_[7]);
	i1.merge( i2);
	BOOST_REQUIRE_EQUAL( 1, i1.size());
	CHECK_INTERVAL_N( fixture.values_[0], fixture.values_[7], i1.begin(), 0);
}

// --------------------------------------------------------------------------------------------------------------------

// 0      1  2 3    4 5  6 7
//        |====|      |====|
// |^^^^^^^^^|      |^^^^|
BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingTwoSets11, TestFixture, test_types)
{
	TestFixture fixture;
	typename TestFixture::interval_set_type i1, i2;
	i2.merge( fixture.values_[0], fixture.values_[2]);
	i1.merge( fixture.values_[1], fixture.values_[3]);
	i2.merge( fixture.values_[4], fixture.values_[6]);
	i1.merge( fixture.values_[5], fixture.values_[7]);
	i1.merge( i2);
	BOOST_REQUIRE_EQUAL( 2, i1.size());
	CHECK_INTERVAL_N( fixture.values_[0], fixture.values_[3], i1.begin(), 0);
	CHECK_INTERVAL_N( fixture.values_[4], fixture.values_[7], i1.begin(), 1);
}

// --------------------------------------------------------------------------------------------------------------------

// 0      1  2 3   4  5 6  7
//        |====|   |====|
// |^^^^^^^^^|        |^^^^|
BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingTwoSets12, TestFixture, test_types)
{
	TestFixture fixture;
	typename TestFixture::interval_set_type i1, i2;
	i2.merge( fixture.values_[0], fixture.values_[2]);
	i1.merge( fixture.values_[1], fixture.values_[3]);
	i1.merge( fixture.values_[4], fixture.values_[6]);
	i2.merge( fixture.values_[5], fixture.values_[7]);
	i1.merge( i2);
	BOOST_REQUIRE_EQUAL( 2, i1.size());
	CHECK_INTERVAL_N( fixture.values_[0], fixture.values_[3], i1.begin(), 0);
	CHECK_INTERVAL_N( fixture.values_[4], fixture.values_[7], i1.begin(), 1);
}

// --------------------------------------------------------------------------------------------------------------------

// 0      1    2    3    4    5
//        |====|    |====|
// |^^^^^^|    |^^^^|    |^^^^|
BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingTwoSets13, TestFixture, test_types)
{
	TestFixture fixture;
	typename TestFixture::interval_set_type i1, i2;
	i2.merge( fixture.values_[0], fixture.values_[1]);
	i1.merge( fixture.values_[1], fixture.values_[2]);
	i2.merge( fixture.values_[2], fixture.values_[3]);
	i1.merge( fixture.values_[3], fixture.values_[4]);
	i2.merge( fixture.values_[4], fixture.values_[5]);
	i1.merge( i2);
	BOOST_REQUIRE_EQUAL( 1, i1.size());
	CHECK_INTERVAL_N( fixture.values_[0], fixture.values_[5], i1.begin(), 0);
}

// --------------------------------------------------------------------------------------------------------------------

// 0    1      2    3    4    5
// |====|      |====|    |====|
//      |^^^^^^|    |^^^^|   
BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingTwoSets14, TestFixture, test_types)
{
	TestFixture fixture;
	typename TestFixture::interval_set_type i1, i2;
	i1.merge( fixture.values_[0], fixture.values_[1]);
	i2.merge( fixture.values_[1], fixture.values_[2]);
	i1.merge( fixture.values_[2], fixture.values_[3]);
	i2.merge( fixture.values_[3], fixture.values_[4]);
	i1.merge( fixture.values_[4], fixture.values_[5]);
	i1.merge( i2);
	BOOST_REQUIRE_EQUAL( 1, i1.size());
	CHECK_INTERVAL_N( fixture.values_[0], fixture.values_[5], i1.begin(), 0);
}

// --------------------------------------------------------------------------------------------------------------------

// 0    1      2    3    4    5
// |====|      |====|    |====|
//  <empty>
BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingTwoSets15, TestFixture, test_types)
{
	TestFixture fixture;
	typename TestFixture::interval_set_type i1, i2;
	i1.merge( fixture.values_[0], fixture.values_[1]);
	i1.merge( fixture.values_[2], fixture.values_[3]);
	i1.merge( fixture.values_[4], fixture.values_[5]);
	i1.merge( i2);
	BOOST_REQUIRE_EQUAL( 3, i1.size());
	CHECK_INTERVAL_N( fixture.values_[0], fixture.values_[1], i1.begin(), 0);
	CHECK_INTERVAL_N( fixture.values_[2], fixture.values_[3], i1.begin(), 1);
	CHECK_INTERVAL_N( fixture.values_[4], fixture.values_[5], i1.begin(), 2);
}

// --------------------------------------------------------------------------------------------------------------------

// 0    1      2    3    4    5
//  <empty>
// |====|      |====|    |====|
BOOST_AUTO_TEST_CASE_TEMPLATE( testMergingTwoSets16, TestFixture, test_types)
{
	TestFixture fixture;
	typename TestFixture::interval_set_type i1, i2;
	i2.merge( fixture.values_[0], fixture.values_[1]);
	i2.merge( fixture.values_[2], fixture.values_[3]);
	i2.merge( fixture.values_[4], fixture.values_[5]);
	i1.merge( i2);
	BOOST_REQUIRE_EQUAL( 3, i1.size());
	CHECK_INTERVAL_N( fixture.values_[0], fixture.values_[1], i1.begin(), 0);
	CHECK_INTERVAL_N( fixture.values_[2], fixture.values_[3], i1.begin(), 1);
	CHECK_INTERVAL_N( fixture.values_[4], fixture.values_[5], i1.begin(), 2);
}

} // namespace
